#ifndef DATAPROCESSOR_H
#define DATAPROCESSOR_H

#include <QThread>
#include <QQueue>
#include <QMutex>
#include <QDateTime>

// 定义数据结构
struct AdData {
    int ad;
    int pos;
    QDateTime timestamp;
};

// 数据处理线程类
class DataProcessor : public QThread {
    Q_OBJECT
public:
    explicit DataProcessor(QObject *parent = nullptr);
    ~DataProcessor();
    
    void addData(const AdData &data);
    void stop();
    
signals:
    void dataProcessed(int count);  // 添加信号用于通知数据处理完成
    
protected:
    void run() override;
    
private:
    QQueue<AdData> dataQueue;
    QMutex mutex;
    bool running;
    static const int BATCH_SIZE = 10; // 批量处理大小
};

#endif // DATAPROCESSOR_H 